//
//  UIDevice+Lc.m
//  18Birdies
//
//  Created by ChenChao on 2017/4/26.
//  Copyright © 2017年 Lc. All rights reserved.
//

#import "UIDevice+Lc.h"

@implementation UIDevice (Lc)

+ (UIInterfaceOrientation)deviceOrientation {
  return [[UIApplication sharedApplication] statusBarOrientation];
}

+ (BOOL)isPortrait {
  return  [self deviceOrientation] == UIInterfaceOrientationPortrait || [self deviceOrientation] == UIInterfaceOrientationPortraitUpsideDown;
}

+ (BOOL)isLandscape {
  return  [self deviceOrientation] == UIInterfaceOrientationLandscapeLeft || [self deviceOrientation] == UIInterfaceOrientationLandscapeRight;
}

+ (UIDeviceScreenSize)screenSize {
  UIDeviceScreenSize screen = UIDeviceScreenSizeUseLessInch;
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
    if (screenHeight == ([UIDevice isPortrait] ? 480.f : 320.f)) {
      screen = UIDeviceScreenSize35Inch;
    } else if (screenHeight == ([UIDevice isPortrait] ? 568.f : 320.f)) {
      screen = UIDeviceScreenSize40Inch;
    } else if (screenHeight == ([UIDevice isPortrait] ? 667.f : 375.f)) {
      screen = UIDeviceScreenSize47Inch;
    } else if (screenHeight == ([UIDevice isPortrait] ? 736.f : 414.f)) {
      screen = UIDeviceScreenSize55Inch;
    } else if (screenHeight == ([UIDevice isPortrait] ? 812.f : 375.f)) {
      screen = UIDeviceScreenSize58Inch;
    } else if (screenHeight == ([UIDevice isPortrait] ? 896.f : 414.f)) {
      screen = UIDeviceScreenSize65Inch;
    }
  } else {
    screen = UIDeviceScreenSize35Inch;
  }
  return screen;
}

+ (BOOL)isOtherUISize {
  return [self screenSize] == UIDeviceScreenSizeUseLessInch;
}

+ (BOOL)isBangUISize {
  return [self screenSize] == UIDeviceScreenSize58Inch ||
         [self screenSize] == UIDeviceScreenSize65Inch;
}
+ (BOOL)is4UISize {
  return [self screenSize] == UIDeviceScreenSize35Inch;
}
+ (BOOL)is5UISize {
  return [self screenSize] == UIDeviceScreenSize40Inch;
}
+ (BOOL)isSmallUISize {
  return [self is4UISize] || [self is5UISize];
}

@end
